package DataStructure.tree.practice;

import DataStructure.tree.TreeNode;

/**
 * 112. 路径总和 https://leetcode.cn/problems/path-sum/
 */
public class HasPathSum {

    public boolean hasPathSum(TreeNode root, int targetSum) {
        //还是要看清题设变量范围
        if(root == null) return false;
        if(root.val == targetSum && root.left == null && root.right == null) return true;
        return hasPathSum(root.left, targetSum - root.val) || hasPathSum(root.right, targetSum - root.val);
    }
}
